package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.bean.OrderBean;
import com.itboye.jinpuyiyuan.bean.RecipeOrderBean;
import com.itboye.jinpuyiyuan.bean.RecipeRecordBean;
import com.itboye.jinpuyiyuan.utils.commonadapter.MutiplyCommonAdapter;
import com.itboye.jinpuyiyuan.utils.commonadapter.ViewHolder;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

public class PrescriptionRecordAdapter   extends MutiplyCommonAdapter<RecipeRecordBean.PayListBean> {
    List<RecipeRecordBean.PayListBean> datas;
    public PrescriptionRecordAdapter(Context context, List<RecipeRecordBean.PayListBean> datas, int... layoutId) {
        super(context, datas, layoutId);
        this.datas=datas;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public void getItemPosition(int position) {


    }

    @Override
    public int getCount() {
        return datas.size();
    }

    public void addData(List<RecipeRecordBean.PayListBean> datas){
        this.datas=datas;
        this.notifyDataSetChanged();
    }
    @Override
    public void convert(ViewHolder holder, RecipeRecordBean.PayListBean recipeOrderBean, int type, int position) {

        holder.setVisible(R.id.payStatusTv,true);
        holder.setText(R.id.medica_content,"就诊科室:"+datas.get(position).getDept_name());
        holder.setText(R.id.medica_time,datas.get(position).getReceipt_date());
        holder.setText(R.id.medica_department,"就诊医生: "+datas.get(position).getDoctor_name());


        DecimalFormat df = new DecimalFormat("#0.00");
        holder.setText(R.id.medica_money,"总费用:  "+df.format(Double.parseDouble(datas.get(position).getPay_amout())/100));

        if (datas.get(position).getOrder_status().equals("0")){ //未付款
            holder.setText(R.id.payStatusTv,"未付款");
            holder.setTextColor(R.id.payStatusTv,mContext.getResources().getColor(R.color.red));
            holder.getView(R.id.payStatusTv).setEnabled(true);
            holder.getView(R.id.payStatusTv).setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shap_payorder_itemredbg));
        }else if (datas.get(position).getOrder_status().equals("1")){ //已付款
            holder.setText(R.id.payStatusTv,"已付款");
            holder.setTextColor(R.id.payStatusTv,mContext.getResources().getColor(R.color.black));
            holder.getView(R.id.payStatusTv).setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shap_payorder_itemgraybg));
        }

        else if (datas.get(position).getOrder_status().equals("2")){ //已退款
            holder.setText(R.id.payStatusTv,"已退款");
            holder.setTextColor(R.id.payStatusTv,mContext.getResources().getColor(R.color.work_address));
            holder.getView(R.id.payStatusTv).setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shap_payorder_itemgraybg));

        }
//        else if (datas.get(position).getPay_status().equals("3")){ //退款中
//            holder.setText(R.id.payStatusTv,"退款中");
//            holder.getView(R.id.payStatusTv).setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shap_payorder_itemgraybg));
//        }
    }
}
